package com.jhc.system.controller;

import com.jhc.api.enums.BusinessStatus;
import com.jhc.common.core.annotation.Page;
import com.jhc.common.core.base.BaseController;
import com.jhc.api.system.domain.Router;
import com.jhc.api.system.domain.vo.RouterVo;
import com.jhc.api.system.service.RouterService;
import com.jhc.common.core.web.page.PageDomain;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.jhc.api.enums.BusinessStatus.SUCCESS;

@RestController
@RequestMapping("router")
public class RouterController extends BaseController<RouterService> {

    @Page
    @PostMapping("/page")
    public List<RouterVo> page() {
        return service.page();
    }

    @GetMapping("/getById")
    public Router getById(@RequestParam("id") Long id) {
        return service.getById(id);
    }

    @PostMapping("/saveOrUpdate")
    public BusinessStatus saveOrUpdate(@RequestBody Router router) {
        service.saveOrUpdate(router);
        return SUCCESS;
    }

    @DeleteMapping("/delete")
    public BusinessStatus delete(@RequestParam("ids") List<Long> ids) {
        service.removeByIds(ids);
        return SUCCESS;
    }
}
